import request from '@/utils/request'

export function addTask(data) {
  return request({
    url: '/v1/task/add',
    method: 'post',
    data: {
      projectId: data.projectId,
      moduleId: data.moduleId,
      devPerson: data.devPersion,
      testPerson: data.testPerson,
      decomposition: data.decomposition,
      describe: data.describe,
      completeVersion: data.vesrion,
      commission: data.commission,
      devBegin: data.devStart,
      devEnd: data.devEnd,
      adjustStart: data.adjustStart,
      selfTest: data.selfTest,
      remarks: data.remarks,
      group: data.group
    }
  })
}

export function editTask(data) {
  return request({
    url: '/v1/task/edit',
    method: 'put',
    data: {
      taskId: data.taskId,
      projectId: data.projectId,
      moduleId: data.moduleId,
      devPerson: data.devPersion,
      testPerson: data.testPerson,
      decomposition: data.decomposition,
      describe: data.describe,
      completeVersion: data.vesrion,
      commission: data.commission,
      devBegin: data.devStart,
      devEnd: data.devEnd,
      selfTest: data.selfTest,
      remarks: data.remarks,
      group: data.group
    }
  })
}

export function findByPage(data, pageSize, pageNum) {
  return request({
    url: '/v1/task/findByPage',
    method: 'get',
    params: {
      group: data.group,
      projectId: data.projectId,
      devPerson: data.devPerson,
      completeVersion: data.version,
      decomposition: data.decomposition,
      statusList: data.statusList,
      pageSize: pageSize,
      pageNum: pageNum,
    }
  })
}

export function findById(taskId) {
  return request({
    url: '/v1/task/findById/' + taskId,
    method: 'get'
  })
}

export function remove(id) {
  return request({
    url: '/v1/task/remove/' + id,
    method: 'delete'
  })
}

export function taskStart(id) {
  return request({
    url: '/v1/task/start/' + id,
    method: 'put'
  })
}

export function taskTest(id) {
  return request({
    url: '/v1/task/test/' + id,
    method: 'put'
  })
}

export function taskReStart(id) {
  return request({
    url: '/v1/task/restart/' + id,
    method: 'put'
  })
}

export function taskFinish(id) {
  return request({
    url: '/v1/task/finish/' + id,
    method: 'put'
  })
}

export function taskCancel(id) {
  return request({
    url: '/v1/task/cancel/' + id,
    method: 'put'
  })
}

export function taskBlock(id, describe) {
  return request({
    url: '/v1/task/block/' + id,
    method: 'put',
    params: {
      describe: describe
    }
  })
}

export function taskSubmit(id, codeRepository) {
  return request({
    url: '/v1/task/submit/' + id,
    method: 'put',
    data: {
      codeRepository: codeRepository
    }
  })
}
